package com.makenv.service;

import com.makenv.dao.UserMapper;
import com.makenv.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {

    @Autowired
    UserMapper userMapper;

    public User selectUser(String username, String password) {
        return userMapper.selectUser(username, password);
    }

    public List<User> showUserList(int startRow, int num) {
        return userMapper.showUserList(startRow, num);
    }

    public int deleteByPrimaryKey(int id) {
        return userMapper.deleteByPrimaryKey(id);
    }

    public int updateByPrimaryKey(int id, String username, String password) {

        User user = new User();
        user.setId(id);
        user.setUsername(username);
        user.setPassword(password);
        return userMapper.updateByPrimaryKey(user);
    }

    public int getUserSum() {
        return userMapper.getUserSum();
    }

    public int insert(String username, String password) {
        User user = new User();
        user.setUsername(username);
        user.setPassword(password);
        return userMapper.insert(user);
    }

}
